/*
 * 8.7
 * Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and
 * pennies (1 cent), write code to calculate the number of ways of representing n cents.
 */
#include <stdio.h>

const int cents[] = { 25, 10, 5, 1 };
const int size = sizeof(cents)/sizeof(cents[0]);

void calc(int n, int i, int *prez)
{
    if (i == size - 1) {
        prez[i] = n;
        for (int k = 0; k < size; k++) {
            printf("%d*%d ", cents[k], prez[k]);
        }
        printf("\n");
        return;
    }
    for (int k = n/cents[i]; k >= 0; k--) {
        int n2 = n - k*cents[i];
        prez[i] = k;
        calc(n2, i+1, prez);
    }
}

int main()
{
    int prez[size];
    calc(50, 0, prez);
    return 0;
}
